@teal-blue: #007eb1;
@background-content: #f2f5f6;
@silver-blue: #b8c6c8;
@silver: #c7d5d8;
@darkHotPink: #e40166;
@toolbar-text: #252525;
// transitions
@opacity-transition: opacity 0.1s 0.2s;
@cubic-transition: cubic-bezier(0.6, -0.28, 0.735, 0.045);
@height-transition: height 0.3s @cubic-transition;
@max-height-transition: max-height 0.3s @cubic-transition;
@width-transition: width 0.3s @cubic-transition;

.has-toolbar {
  .pusher {
    height: 100px;
    transition: @height-transition;
  }
}

.has-toolbar-collapsed {
  .pusher {
    height: 20px;
    transition: @height-transition;
  }
}

body:not(.has-sidebar):not(.has-sidebar-collapsed) {
  #toolbar {
    /* Mobile */
    @media only screen and (max-width: @largestMobileScreen) {
      [class*='mobile hidden'],
      [class*='tablet only']:not(.mobile),
      [class*='computer only']:not(.mobile),
      [class*='large screen only']:not(.mobile),
      [class*='widescreen only']:not(.mobile),
      [class*='or lower hidden'] {
        display: none !important;
      }
    }

    /* Tablet / iPad Portrait */
    @media only screen and (min-width: @tabletBreakpoint) and (max-width: @largestTabletScreen) {
      [class*='mobile only']:not(.tablet),
      [class*='tablet hidden'],
      [class*='computer only']:not(.tablet),
      [class*='large screen only']:not(.tablet),
      [class*='widescreen only']:not(.tablet),
      [class*='or lower hidden']:not(.mobile) {
        display: none !important;
      }
    }

    /* Computer / Desktop / iPad Landscape */
    @media only screen and (min-width: @computerBreakpoint) and (max-width: @largestSmallMonitor) {
      [class*='mobile only']:not(.computer),
      [class*='tablet only']:not(.computer),
      [class*='computer hidden'],
      [class*='large screen only']:not(.computer),
      [class*='widescreen only']:not(.computer),
      [class*='or lower hidden']:not(.tablet):not(.mobile) {
        display: none !important;
      }
    }

    /* Large Monitor */
    @media only screen and (min-width: @largeMonitorBreakpoint) and (max-width: @largestLargeMonitor) {
      [class*='mobile only']:not([class*='large screen']),
      [class*='tablet only']:not([class*='large screen']),
      [class*='computer only']:not([class*='large screen']),
      [class*='large screen hidden'],
      [class*='widescreen only']:not([class*='large screen']),
      [class*='or lower hidden']:not(.computer):not(.tablet):not(.mobile) {
        display: none !important;
      }
    }

    /* Widescreen Monitor */
    @media only screen and (min-width: @widescreenMonitorBreakpoint) {
      [class*='mobile only']:not([class*='widescreen']),
      [class*='tablet only']:not([class*='widescreen']),
      [class*='computer only']:not([class*='widescreen']),
      [class*='large screen only']:not([class*='widescreen']),
      [class*='widescreen hidden'],
      [class*='widescreen or lower hidden'] {
        display: none !important;
      }
    }
  }
}

#toolbar {
  .toolbar {
    position: fixed;
    z-index: 100;
    display: flex;
    width: 100%;
    height: 20px;
    flex-direction: column;
    background-color: #fff;
    box-shadow: 0 1px 2px 0 #c7d5d8;
    transition: @height-transition;

    &.expanded {
      height: 100px;

      .toolbar-actions {
        opacity: 1;
        transition: @opacity-transition;

        &.hidden {
          opacity: 0;
          transition: @opacity-transition;
        }
      }

      .toolbar-body {
        height: 100px;
      }

      .toolbar-bottom {
        opacity: 1;
        transition: @opacity-transition;
      }

      .toolbar-button-spacer {
        margin-left: auto;
      }
    }

    .toolbar-handler {
      button {
        opacity: 0.3;
      }

      // State colors
      .published:before {
        background: @teal-blue;
      }

      .private:before {
        background: @darkHotPink;
      }
    }

    &-content {
      overflow: hidden;
      max-height: 0;
      background-color: #fff;
      box-shadow: 0 1px 2px 0 #c7d5d8;
      opacity: 0;
      // Removing this because is causing grey scroll appears
      // overflow-y: scroll;
      transition: @max-height-transition, opacity 0.3s 0.3s;

      &.show {
        max-height: 900px;
        opacity: 1;
        transition: @max-height-transition, opacity 0.3s 0.3s;
      }
    }

    &-body {
      display: flex;
      height: 0;
      flex-direction: row-reverse;
      transition: @height-transition;

      a,
      button {
        margin-left: 20px;
        color: @brown;
        cursor: pointer;
      }

      button {
        // Default reset for button
        padding: 0;
        border: 0;
        background: transparent;
        text-align: initial;

        &:focus {
          outline: none;
        }

        &.ui {
          margin-right: 0;

          svg.icon {
            margin: 0;
          }
        }
      }
    }

    &-actions {
      display: flex;
      height: 100%;
      flex: 1;
      flex-direction: row-reverse;
      align-items: center;
      padding: 0 20px;
      opacity: 0;
      transition: @opacity-transition;

      .contents {
        color: @teal-blue;

        &.circled {
          border-color: rgba(0, 0, 0, 0);
          background-color: rgba(0, 0, 0, 0.05);
          color: #826a6a;
        }
      }

      .save {
        color: @teal-blue;
      }

      .cancel {
        color: @darkHotPink;
      }

      .edit {
        color: @teal-blue;
      }

      a,
      button {
        display: block;
      }
    }

    &-handler {
      position: absolute;
      bottom: 0;
      display: flex;
      width: 100%;
      justify-content: center;

      button {
        width: @toolbarWidth;
        height: 20px;
        padding: 0;
        border: 0;
        background-color: transparent;
        cursor: pointer;
        transition: opacity 0.3s;

        &::before {
          position: relative;
          display: block;
          width: 100%;
          height: 4px;
          background-color: red;
          content: '';
        }
      }
    }

    &-bottom {
      display: flex;
      flex-direction: row-reverse;
      // flex: 1;
      align-items: center;
      opacity: 0;
      transition: @opacity-transition;

      .user {
        display: none;
      }

      .divider {
        display: none;
      }
    }
  }

  .toolbar-content,
  .toolbar {
    button {
      // Default reset for button
      padding: 0;
      border: 0;
      background: transparent;
      cursor: pointer;
      text-align: initial;

      &:focus {
        outline: none;
      }
    }
  }

  .toolbar-content {
    z-index: 3;
    overflow: auto;
    box-shadow: 0 1px 2px 0 #c7d5d8;
  }

  .pusher-puller {
    position: relative;
    z-index: 2;
    display: flex;
    // min-height: 500px;
    transition: transform 300ms linear;
    will-change: transform;

    // > * {
    // position: absolute;
    // width: 100%;
    // height: 100%;
    // top: 0;
    // left: 0;
    // }

    // > *:first-child {
    //   position: relative;
    // }
  }

  @media only screen and (min-width: @largestMobileScreen) {
    .toolbar {
      width: @toolbarWidthMin;
      height: 100%;
      flex-direction: row;
      justify-content: flex-end;
      transition: @width-transition;

      & + .pusher {
        margin-right: @toolbarWidthMin;
        transition: margin-right 0.3s @cubic-transition;
      }

      &.expanded {
        width: @toolbarWidth;
        height: 100%;

        & + .pusher {
          margin-right: @toolbarWidth;
          transition: margin-right 0.3s @cubic-transition;
        }

        .toolbar-body {
          height: 100%;
        }

        .toolbar-actions {
          flex-direction: column;

          .ui.dropdown.left {
            width: 100%;
            text-align: center;
          }
        }

        .toolbar-bottom {
          .user {
            opacity: 1;
            transition: @opacity-transition;
          }

          .divider {
            width: 40px;
            height: 20px;
            border-top: 1px solid #c7d5d8;
            opacity: 1;
            transition: @opacity-transition;
          }
        }
      }

      &-content {
        position: fixed;
        left: @toolbarWidth;
        width: 320px;
      }

      &-body {
        display: flex;
        width: 100%;
        height: 100%;
        flex-direction: column;
        transition: @width-transition;

        a,
        button {
          margin-bottom: 20px;
          margin-left: 0;
        }
      }

      &-actions {
        flex: 1;
        flex-direction: column;
        padding: 20px 0;

        .more {
          flex: 0;
        }
      }

      &-bottom {
        flex: 1;
        flex-direction: column-reverse;
        justify-content: flex-start;

        .user {
          display: block;
          opacity: 0;
        }

        .divider {
          display: block;
          opacity: 0;
        }
      }

      &-handler {
        display: flex;
        width: @toolbarWidthMin;
        height: 100%;
        flex-direction: column;
        justify-content: center;

        button {
          width: @toolbarWidthMin;
          height: @toolbarWidth;

          &::before {
            left: 8px;
            width: 4px;
            height: 100%;
          }
        }
      }
    }

    .pusher-puller {
      > * {
        // TODO: look how to standard for all devices
        width: 320px;
      }
    }
  }

  // Personal Tools
  .pastanaga-menu {
    width: 100vw;
    height: calc(100vh - 100px);

    &.has-inner-actions {
      height: 100vh;

      @media only screen and (min-width: @largestMobileScreen) {
        height: auto;
      }
    }

    .ui.container {
      margin-right: 0 !important;
      margin-left: 0 !important;
    }

    header {
      display: flex;
      height: 60px;
      align-items: center;
      justify-content: space-between;
      padding: 8px 20px;
      border-bottom: 4px solid @silver-blue;

      h2 {
        overflow: hidden;
        max-width: 100%;
        flex: 1 0 auto;
        margin: 0;
        font-size: 16px;
        font-weight: 500;
        text-overflow: ellipsis;
        white-space: nowrap;
      }

      a {
        display: flex;
      }

      &.pulled {
        justify-content: flex-start;
        padding-right: 10px;
        padding-left: 10px;

        button {
          margin-right: 10px;
        }
      }
    }

    .ui.form {
      height: 100%;
    }

    .ui.raised.segments {
      display: flex;
      height: calc(100vh - 60px);

      @media only screen and (min-width: @largestMobileScreen) {
        max-height: calc(520px - 60px);
      }

      .ui.segment:not(.actions) {
        flex: 1 1 auto;
        overflow-y: auto;
      }

      .ui.clearing.segment.actions:after {
        content: initial;
      }
    }

    @media only screen and (min-width: @largestMobileScreen) {
      width: 320px;
      height: auto;
    }
  }

  .pastanaga-menu-list {
    ul {
      display: flex;
      flex-direction: column;
      justify-content: center;
      padding: 10px 20px;
      margin-top: 0;
      list-style: none;
    }

    li {
      // padding: 5px 0;

      a,
      button {
        display: flex;
        width: 100%;
        height: 45px;
        align-items: center;
        justify-content: space-between;
        padding: 0;
        border: none;
        background-color: transparent;
        color: @toolbar-text;
        cursor: pointer;
        font-family: Poppins;
        font-size: 14px;
        font-weight: 500;
        text-align: left;
        text-transform: uppercase;

        svg {
          color: @teal-blue;
        }
      }
    }

    li:not(.state-select):not(.display-select) {
      border-bottom: 1px solid @silver-blue;
    }

    .pastanaga-menu-label {
      margin-right: 12px;
    }

    .pastanaga-menu-value {
      font-weight: 300;
      text-transform: initial;
    }
  }

  .personal-tools {
    header {
      .back,
      .vertical.divider {
        @media only screen and (min-width: @largestMobileScreen) {
          display: none;
        }

        margin-right: 10px;
      }

      .icon.logout {
        color: @darkHotPink;
      }
    }

    .avatar {
      height: 220px;
      background-color: #f2f5f6;

      img {
        width: 100%;
        height: 100%;
        object-fit: contain;
        object-position: top;
      }

      &.default {
        display: flex;
        align-items: center;
        justify-content: center;
        color: @brown;
      }
    }

    .stats {
      ul {
        display: flex;
        justify-content: center;
        padding: 15px 0;
        margin: 0;
        background-color: #f2f5f6;
        color: #878f93;
        list-style: none;
      }

      li {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 0 10px;

        span:first-child {
          font-size: 30px;
          font-weight: 200;
        }

        span:last-child {
          font-size: 12px;
          font-weight: 500;
          text-transform: uppercase;
        }
      }
    }
  }

  // Profile
  .vertical.divider {
    height: 30px;
    border-left: 1px solid @silver;
    margin-right: 20px;
  }

  .profile,
  .personal-tools {
    header {
      button {
        color: @teal-blue;
      }
    }
  }

  .menu-more {
    header {
      svg {
        color: #d12c67;
      }
    }

    .more-user {
      @media only screen and (min-width: @largestMobileScreen) {
        display: none;
      }
    }

    .state-select,
    .display-select {
      .inline.field .wrapper {
        min-height: unset;
      }

      .react-select-container {
        flex: 1 0 75%;
      }

      label {
        font-size: 14px;
        font-weight: 500;
        text-transform: uppercase;
      }
    }
  }

  .toolbar-compare-translations-wrapper {
    position: relative;

    .toolbar-button-compare-translations .icon {
      padding: 4px;
    }

    .compare-languages {
      @media (max-width: @largestMobileScreen - 1) {
        position: fixed;
        top: 101px;
        left: 0;
      }
      @media (min-width: @largestMobileScreen) {
        position: absolute;
        top: 50%;
        left: 56px;
        transform: translateY(-50%);
      }

      .pastanaga-menu {
        button {
          margin: 0;
        }
      }
    }
  }
}

// Reasoning: This is to allow scrolling inside the types
// You can't make this to happen in a fixed element that does not have
// fixed height, so for small viewports height, we are forcing the container
// to have a full height, then the inner container knows when
// and how to scroll.
@media only screen and (max-height: 400px) {
  #toolbar .toolbar-content.show {
    height: 100%;
  }
}

// Orphaned CSS
.ui.dropdown .menu.left {
  right: 0;
  left: auto;
}

.ui.segment.dashed {
  border: 3px dashed #ccc;
  box-shadow: none;
}

@media only screen and (max-width: 767px) {
  .ui.menu.stackable > .menu,
  .ui.menu.stackable > .menu.right {
    display: block;
  }
}
// End Orphaned CSS
